package com.sgb.kjwl.view.ui.activity.lease;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;
import androidx.fragment.app.Fragment;

import com.sgb.kjwl.AppLazyFragment;
import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.ActivityAskLeaseForRent2Binding;
import com.sgb.kjwl.databinding.ActivityAskLeaseForRentBinding;
//import com.sgb.kjwl.di.machine.DaggerMachineComponent;
import com.sgb.kjwl.view.ui.fragment.machine.AskLeaseHallFragment;
import com.swgk.core.recyclerview.adapter.FragPagerAdapter;

import java.util.ArrayList;

/**
 * 求租大厅(需求大厅)
 */
@Deprecated
public class AskLeaseFragment2 extends AppLazyFragment {

//    @Inject
//    AskLeaseModel viewModel;

    private ActivityAskLeaseForRent2Binding binding;
    private FragPagerAdapter pagerAdapter;
    private ArrayList<Fragment> mFragments;
    private String[] titles = {"求租信息", "竞价租赁", "集采租赁"};
    private int position;

//    @Override
//    protected void setupActivityComponent(AppComponent appComponent) {
//        DaggerMachineComponent.builder().appComponent(appComponent)
//                .machineModule(new MachineModule(this))
//                .build()
//                .inject(this);
//    }
//
//    public static void start(Context context) {
//        Intent intent = new Intent();
//        intent.setClass(context, AskLeaseFragment2.class);
//        context.startActivity(intent);
//    }
//
//    public static void start(Context context, int position) {
//        Intent intent = new Intent();
//        intent.putExtra("position", position);
//        intent.setClass(context, AskLeaseFragment2.class);
//        context.startActivity(intent);
//    }

    public static AskLeaseFragment2 newInstance(int position){
        AskLeaseFragment2 fragment = new AskLeaseFragment2();
        Bundle bundle = new Bundle();
        bundle.putInt("position", position);
        fragment.setArguments(bundle);
        return fragment;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        binding = DataBindingUtil.inflate(inflater, R.layout.activity_ask_lease_for_rent2, container, false);
        return binding.getRoot();
    }

    @Override
    protected void initView() {
        position = getArguments().getInt("position", 0);
    }

    @Override
    protected void onLazyLoad() {
        init();
    }

    private void init() {
        mFragments = new ArrayList<>();
        mFragments.add(AskLeaseHallFragment.newInstance(0,true));//需求大厅
        mFragments.add(AskLeaseHallFragment.newInstance(1,true));//竞价租赁
        mFragments.add(AskLeaseHallFragment.newInstance(2,true));//集采租赁
        pagerAdapter = new FragPagerAdapter(getChildFragmentManager(), mFragments);
        binding.viewpager.setOffscreenPageLimit(titles.length);
        binding.viewpager.setAdapter(pagerAdapter);
        binding.tablayout.setViewPager(binding.viewpager, titles);
        binding.viewpager.setCurrentItem(position);
    }

}
